<!-- 专题 -->
<template>
  <div class="zhuanti">
    <div v-for="item in data" :key="item.id" class="box">
      <img class="pic" v-lazy="item.scene_pic_url" alt="" />
      <div class="title">{{ item.title }}</div>
      <div class="tip">{{ item.subtitle }}</div>
      <div class="price">$ {{ item.price_info }} 元</div>
    </div>
    <van-pagination
      v-model="currentPage"
      :items-per-page="item_per_page"
      :page-count="totalPages"
      mode="simple"
      @change="changeFn"
    >
    </van-pagination>
  </div>
</template>

<script>
import { GetTopicApi } from "@/https/https";

export default {
  // name: '21181224Topic',

  data() {
    return {
      currentPage: 1,         //当前页
      totalPages: "2",        // 总页数
      item_per_page: 10,      //每页数据条数
      data: [],               //数据
    };
  },
  

  methods: {
      changeFn() {
          this.GetTopicApi();
          console.log(this.currentPage);
      },
      GetTopicApi() {
        GetTopicApi({ page: this.currentPage,size: this.items_per_page }).then((res) =>{
          console.log(res);
          this.data = res.data.data.data;
          this.totalPages = res.data.data.totalPages;
          this.items_per_page = res.data.data.pageSize;
          this.currentPage = res.data.data.currentPage;
        })
      }
    },
  created() {
        // 切换页面
        this.GetTopicApi();
  },
};
</script>

<style lang = "less">
.van-pagination__item {
  color: darkred;
}
.van-pagination__item--disabled {
  color: #333;
}
.van-pagination__page-desc {
  display: none;
  /* /deep/样式穿透 一般用于修改ui框架中的默认样式i */
}
.zhuanti {
  padding-bottom: 100px;
  .box {
    background-color: #fff;
    text-align: center;
    padding-bottom: 10px;
    margin-bottom: 20px;
    .pic {
      width: 100%;
    }
    .title {
      font-size: 18px;
      margin: 10px 0;
    }
    .tip {
      font-size: 16px;
      margin: 20px 0;
      color: rgb(31, 31, 31);
      overflow: hidden;
      text-overflow: ellipsis;
      /* 弹性伸缩盒子模型显示 */
      display: -webkit-box;
      /* 限制在一个块元素显示的文本的行数 */
      -webkit-line-clamp: 1;
      /* 设置或检索伸缩盒对象的子元素的排列方式 */
      -webkit-box-orient: vertical;
    }
    .price {
      color: rgb(155, 0, 0);
      margin-bottom: 10px;
    }
  }
}
</style>